package io.geekidea.boot.generator.jdbc;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;

public class DbMetadata {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.cj.jdbc.Driver");
        String url = "jdbc:mysql://localhost:3306/spring_boot_plus?tinyInt1isBit=false";
        String username = "root";
        String password = "123456";
        Connection connection = DriverManager.getConnection(url, username, password);
        DatabaseMetaData metaData = connection.getMetaData();
        ResultSet set = metaData.getColumns("spring_boot_plus", "", "sys_log", "source");
        while (set.next()) {
            System.out.println("Column Name: " + set.getString("COLUMN_NAME"));
            System.out.println("Data Type: " + set.getInt("COLUMN_SIZE"));
            System.out.println("Type Name: " + set.getString("TYPE_NAME"));
        }
    }
}
